#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int v[203][203];
struct Node {
    int row;
    int col;
};
int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, -1, 1};

bool ok(int fr, int fc, int m, int n) {
    if (fr < 0 || fr >= m || fc < 0 || fc >= n) return 0;
    return 1;
}

void solve(vector<vector<char>>& board) {
    int m = board.size();
    int n = board[0].size();
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (board[i][j] == 'X') continue;
            if (v[i][j] == -1) continue;
            if (v[i][j] == 0 &&
                (i == 0 || i == m - 1 || j == 0 || j == n - 1)) {
                v[i][j] = -1;
                queue<Node> Q;
                Q.push(Node{i, j});
                while (!Q.empty()) {
                    int r = Q.front().row;
                    int c = Q.front().col;
                    Q.pop();
                    for (int i = 0; i < 4; i++) {
                        int fr = r + dr[i];
                        int fc = c + dc[i];
                        if (ok(fr, fc, m, n) && board[fr][fc] == 'O' &&
                            v[fr][fc] == 0) {
                            v[fr][fc] = -1;
                            Q.push(Node{fr, fc});
                        }
                    }
                }
            }
        }
    }

    // modify
    for (int i = 0; i < m; i++)
        for (int j = 0; j < n; j++) {
            if (board[i][j] == 'O' && v[i][j] != -1) board[i][j] = 'X';
        }
}

int main() {
    vector<vector<char>> board = {
        {'O', 'O', 'O'}, {'O', 'O', 'O'}, {'O', 'O', 'O'}};
    solve(board);
    cout << v[1][1] << endl;
    return 0;
}